package com.zqh.categoryquery.controller;

import com.zqh.categoryquery.service.CategoryQueryService;
import com.zqh.myfmmall.result.Result;
import com.zqh.myfmmall.vo.CategoryVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description :
 * @Author :kono淇杭哒、
 * @Create 2022-02-18 2:15
 */
@RestController
@RequestMapping("category")
public class CategoryQueryController{
    @Resource
    private CategoryQueryService categoryQueryService;

    @GetMapping("retrieveAllVos")
    public Result retrieveAllVo(){
        List<CategoryVo> categoryVos = categoryQueryService.selectAllCategorieVo();
        return Result.success(categoryVos);
    }

    @GetMapping("retrieveFirstLevalCategoryVos")
    public Result retrieveFirstLevalCategoryVos(){
        return categoryQueryService.selectFirstLevelCategoryVo();
    }

    @GetMapping("retrieveByParentId/{parentId}")
    public Result retrieveByParentId(@PathVariable("parentId") String parentId){
        List<CategoryVo> categoryVos = categoryQueryService.selectVoByParentId(parentId);
        return Result.success(categoryVos);
    }
}
